package i.i.myapplication;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class WeChatDetailActivity extends AppCompatActivity {

    private EditText editTitle, editDescription;
    private ImageView imageView;
    private Button btnAdd;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wechat_detail);

        imageView = findViewById(R.id.imageView);
        editTitle = findViewById(R.id.editTitle);
        editDescription = findViewById(R.id.editDescription);
        btnAdd = findViewById(R.id.btnAdd);

        btnAdd.setOnClickListener(v -> {
            String title = editTitle.getText().toString().trim();
            String desc = editDescription.getText().toString().trim();

            if (title.isEmpty() || desc.isEmpty()) {
                Toast.makeText(this, "标题和描述不能为空", Toast.LENGTH_SHORT).show();
                return;
            }

            // 准备数据返回
            Intent intent = new Intent();
            intent.putExtra("title", title);
            intent.putExtra("description", desc);
            intent.putExtra("imageResId", R.drawable.default_news_img); // 传图片资源id

            setResult(Activity.RESULT_OK, intent);
            finish();
        });
    }
}
